package com.kaifamiao.bytestreams;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;

/**
 * FileOutputStream( String pathname, boolean append )
 * FileOutputStream( File f, boolean append )
 */
public class OutputStreamTest2 {

    public static void main(String[] args) throws IOException {
        File f = new File( "D:/", "time.txt" );
        // 当 FileOutputStream 构造方法第二个参数为 true 时表示向文件中追加新输出的内容
        OutputStream out = new FileOutputStream( f , true);

        LocalDateTime datetime = LocalDateTime.now();
        String str = datetime.toString();
        byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
        out.write( bytes );
        out.write( '\n' );

        out.close();
    }

}
